<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
  </head>
  <body>
    <div id="app">
      <h1>{{count}}</h1>
      <hr />
      <xx-counter v-on:xxx-yyy="increment"></xx-counter>
      <xx-counter v-on:xxx-yyy="increment"></xx-counter>
    </div>
    <script>
      Vue.component("xx-counter", {
        template: `<button @click='$emit("xxx-yyy", 5, $event)'>子组件</button>`,
        // 这里的$event 指向 dom事件对象
      });

      new Vue({
        el: "#app",
        data: {
          count: 100,
        },
        methods: {
          increment: function (a, b) {
            // console.log(a, b);
            // this.count += 1;

            // this.count += a;
            this.count = a
          },
        },
      });
    </script>
  </body>
</html>
